<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<jsp:include  page="../common/file.jsp"/>
<head>
</head>
<body class="dialog_body" id="password_edit_background">
<form id="updatepwd_form" method="get" action="${pageContext.request.contextPath}/login/logout" target="_parent">
<div class="dialog-two-div">
	<table class="dialog-two-table">
		<tr>
			<td class="dialog-td-right" style="width:43%;text-align:right;color:#000000">原密码</td>
			<td class="dialog-td-left" style="padding-left:10px;">
				<input type="password" id="oldPassword" name="oldPassword" maxlength="20" placeholder="请输入原密码" validate="not-null2"/>
				<span class="redtext">*</span>
			</td>
		</tr>
		<tr>
			<td class="dialog-td-right" style="width:43%;text-align:right;color:#000000">新密码 </td>
			<td class="dialog-td-left" style="padding-left:10px;">
				<input type="password" id="newPassword" name="newPassword" maxlength="20" placeholder="请输入新密码" validate="not-null2,password2"/>
				<span class="redtext">*</span>
			</td>
		</tr>
		<tr>
			<td class="dialog-td-right" style="width:43%;text-align:right;color:#000000">确认密码 </td>
			<td class="dialog-td-left" style="padding-left:10px;">
				<input type="password" id="confirmPassword" name="confirmPassword" maxlength="20" placeholder="请输入确认密码" validate="not-null2"/>
				<span class="redtext">*</span>
			</td>
		</tr>
	</table>
	<table class="dialog-two-table">
		<tr class="dialog-two-button">
			<td colspan=2 >
				<button type="button" class="btn btn-warning submit-btn">提 交</button>
			</td>
		</tr>
	</table>
</div>
</form>
<script type="text/javascript">
		
	// 提交保存
	function submitForm() {
		
		var $oldPassword = $('#oldPassword').val();
		var $newPassword = $('#newPassword').val();
		var $confirmPassword = $('#confirmPassword').val();
		
		if ($newPassword != $confirmPassword) {
			art.dialog.alert('新密码和确认密码不匹配！');
			scroll(0,0);
			return false;
		}

		// JS对密码进行加密
		$oldPassword = $.md5($oldPassword);
		$newPassword = $.md5($newPassword);
		
		var ctxt = "${pageContext.request.contextPath}";
		art.dialog.tips('正在提交...', 0.5);
		$.post(ctxt + "/login/updatePassword", {"oldPassword": $oldPassword, "newPassword": $newPassword}, function(msg) {
			if (msg != undefined && msg.status == 0) {
				art.dialog.alert(msg.message, function() {
					// 注销,返回登录页
					$('#updatepwd_form').submit();
				}); 
			} else {
				art.dialog.alert(msg.message);
			}
		},'json');
		
	}
	
</script>
</body>

  
